package Sortion;

import java.io.FileReader;
import java.lang.management.MonitorInfo;
import java.util.TooManyListenersException;

public class SelectionSort {
    public static void main(String[] args) {
        int[] arr = {5,34,1324,535,66,577,678,8};
        SelectionSort(arr);
        for(int i = 0; i < arr.length; i++){
            System.out.print(arr[i] + "  ");
        }
    }


    public static void SelectionSort(int[] arr){
        for(int i = 0; i <arr.length; i++){
            int minIndex = i;
            for(int j = i+1; j <arr.length; j++){
                if(arr[j] < arr[minIndex]){
                    minIndex = j;
                }
            }
            int temp = arr[i];
            arr[i] = arr[minIndex];
            arr[minIndex] = temp;

        }
    }
}
